package com.example.common.base;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import android.view.ViewGroup;

import java.util.List;

/**
 * @author skygge
 * @date 2019-12-31.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：
 */
public class MyPagerAdapter extends FragmentStatePagerAdapter {

    private List<Fragment> fragmentList;

    public MyPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setFragment(List<Fragment> fragmentList) {
        this.fragmentList = fragmentList;
    }

    public void setTitleAndFragment(List<Fragment> fragmentList) {
        this.fragmentList = fragmentList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public Fragment getItem(int i) {
        return fragmentList.get(i);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return PagerAdapter.POSITION_NONE;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
    }
}
